﻿<!--/************************************************************************************  
' Copyright (C) 2009 Anthony Bouch (http://www.58bits.com) under the terms of the
' Microsoft Public License (Ms-PL http://www.codeplex.com/precode/license)
'***********************************************************************************/-->
    <ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="clr-namespace:System;assembly=mscorlib"   
    >

  <Style x:Key="CheckBoxFocusVisual">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Border>
            <Rectangle
              Margin="15,0,0,0"
              StrokeThickness="1"
              Stroke="#60000000"
              StrokeDashArray="1 2"/>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>


  <Style x:Key="{x:Type CheckBox}" TargetType="CheckBox">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="FocusVisualStyle"    Value="{StaticResource CheckBoxFocusVisual}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="CheckBox">
          <ControlTemplate.Resources>
            <Storyboard x:Key="ImageTimeline1">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CheckMark" Storyboard.TargetProperty="Opacity">
                <SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="1"/>
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="ImageTimeline2">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CheckMark" Storyboard.TargetProperty="Opacity">
                <SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="0"/>
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
          </ControlTemplate.Resources>
          <BulletDecorator Background="Transparent">
            <BulletDecorator.Bullet>
              <Grid Width="15" Height="15">
                <Border x:Name="Border"
                  Width="13"
                  Height="13"
                  CornerRadius="0"
                  Background="Transparent"
                  BorderThickness="1"
                  BorderBrush="{DynamicResource FontForecolor}">
                </Border>
                <Path Opacity="0" 
                  Width="14" Height="14"
                  x:Name="CheckMark"
                  SnapsToDevicePixels="False"
                  Stroke="{DynamicResource FontForecolor}"
                  StrokeThickness="2"
                  Data="M 3,7 L 7,10 L 13,0" />
              </Grid>
            </BulletDecorator.Bullet>
            <ContentPresenter Margin="4,0,0,0"
              VerticalAlignment="Center"
              HorizontalAlignment="Center"
              RecognizesAccessKey="True"/>
          </BulletDecorator>
          <ControlTemplate.Triggers>
            <!--<Trigger Property="IsChecked" Value="false">
              <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
            </Trigger>-->
            <Trigger Property="IsChecked" Value="{x:Null}">
              <Setter TargetName="CheckMark" Property="Data" Value="M 0 7 L 7 0" />
            </Trigger>
            <!--<Trigger Property="IsMouseOver" Value="true">
              <Setter TargetName="Border" Property="Background" Value="{StaticResource DarkBrush}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="true">
              <Setter TargetName="Border" Property="Background" Value="{StaticResource PressedBrush}" />
              <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource PressedBorderBrush}" />
            </Trigger>-->
            <Trigger Property="IsEnabled" Value="false">
              <!--<Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}" />-->
              <Setter TargetName="Border" Property="BorderBrush" Value="{ DynamicResource DisabledFontForecolor }" />
              <Setter TargetName="CheckMark" Property="Stroke" Value="{ DynamicResource DisabledFontForecolor }" />
              <Setter Property="Foreground" Value="{DynamicResource DisabledFontForecolor }"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
              <Trigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource ImageTimeline1}"/>
              </Trigger.EnterActions>
              <Trigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource ImageTimeline2}"/>
              </Trigger.ExitActions>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>
